<!--
Author: W3layouts
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
-->
<?php 
header('content-type:text/html;charset=utf8');
require('../public/function.php');
$id=isset($_GET['id'])?$_GET['id']:'';
$arr=select('blog','blog',"where id=$id");
//var_dump($arr);die;

//var_dump($pinglun);die;

$everypage=3;//每页条数
$p=isset($_GET['p'])?$_GET['p']:'1';//当前页
$offset=($p-1)*$everypage;

$link = mysql_connect('localhost', 'root', 'root') or die('连接数据库失败' . mysql_error());
mysql_select_db('blog') or die('选库失败' . mysql_error()) ;
mysql_set_charset('utf8');
$sql = "select * from `pinglun` where pid='$id' limit $offset,$everypage";
//var_dump ($sql);
$res=mysql_query($sql);
//$a=mysql_fetch_assoc($res);
$arrd=array();       
while($a=mysql_fetch_assoc($res)){
    //var_dump($a);echo '<br>';
  $arrd[]=$a;  
}
$count5=mysql_query("select count(*) as c from pinglun where pid='$id'");
$rs=mysql_fetch_assoc($count5);
$count=$rs['c'];//总条数
$allpage=ceil($count/$everypage);//总页数

$prev=$p-1;
if($prev<=1){
    $prev=1;
}
$next=$p+1;
if($next>=$allpage){
    $next=$allpage;
}

//$pinglun=select('blog','pinglun');
 ?>
<!DOCTYPE html>
<html>
<head>
<title>Quickly a Blogging Category Flat Bootstarp Resposive Website Template | Single :: w3layouts</title>
<!-- for-mobile-apps -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Quickly Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
		function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- //for-mobile-apps -->
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<!-- js -->
<script src="js/jquery-1.11.1.min.js"></script>
<!-- //js -->
<!-- start-smoth-scrolling -->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
	jQuery(document).ready(function($) {
		$(".scroll").click(function(event){		
			event.preventDefault();
			$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
		});
	});
</script>
<!-- start-smoth-scrolling -->
</head>
	
<body>
<!-- banner-body -->
	<div class="banner-body abt">
		<div class="container">
<!-- header -->
			<div class="header">
				<div class="header-nav">
					<nav class="navbar navbar-default">
						<!-- Brand and toggle get grouped for better mobile display -->
						<div class="navbar-header">
						  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
							<span class="sr-only">Toggle navigation</span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
						  </button>
						   <a class="navbar-brand" href="index.php"><span>Q</span>uickly</a>
						</div>

						<!-- Collect the nav links, forms, and other content for toggling -->
						<div class="collapse navbar-collapse nav-wil" id="bs-example-navbar-collapse-1">
						 <ul class="nav navbar-nav">
							<li class="hvr-bounce-to-bottom"><a href="index.php">Home</a></li>
							<li class="hvr-bounce-to-bottom"><a href="about.php">About</a></li>
							<li class="hvr-bounce-to-bottom"><a href="Portfolio.php">Portfolio</a></li>
							<li class="hvr-bounce-to-bottom"><a href="Pages.php">Pages</a></li>
							<li class="hvr-bounce-to-bottom"><a href="contact.php">Contact Us</a></li>
						  </ul>
						  <div class="sign-in">
							<ul>
								<?php   if(!empty($_COOKIE['name'])){echo "<li><a href=''>{$_COOKIE['name']}</a>/</li>
                                <li><a href='quit.php'>退出</a></li>";}else{echo "<li><a href='login.php'>Sign In </a>/</li>
                                <li><a href='register.php'>Register</a></li>";}
                                ?>
							</ul>
							</div>
						</div><!-- /.navbar-collapse -->
					</nav>
				</div>
	
			<!-- search-scripts -->
			<script src="js/classie.js"></script>
			<script src="js/uisearch.js"></script>
				<script>
					new UISearch( document.getElementById( 'sb-search' ) );
				</script>
			<!-- //search-scripts -->
			</div>
<!-- //header -->
<!-- single -->
	<div class="single-page-artical"><?php 
            foreach($arr as $ke=>$va){
                echo "
		<div class='artical-content'>
			<h3>Lorem Ipsum is simply dummy text</h3>
			<img class='img-responsive' src='images/banner.jpg' alt=' ' />
			<p>".$va['content']."
                </p>
		</div>
		<div class='artical-links'><ul>
			<li><small> </small><span>".$va['ctime']."</span></li>
				<li><a href='#'><small class='admin'> </small><span>".$va['author']."</span></a></li>
				<li><a href='#'><small class='no'> </small><span>No comments</span></a></li>
				<li><a href='#'><small class='posts'> </small><span>View posts</span></a></li>
				<li><a href='#'><small class='link'> </small><span>permalink</span></a></li></ul>
        </div>";
                }?>
			
		<div class="comment-grid-top">
			<h3>评论区</h3>
			<?php 



            foreach($arrd as $u=>$i){echo "<div class='comments-top-top'>
				<div class='top-comment-left'>
					<a href='#'><img class='img-responsive' src='images/co.png' alt='></a>
				</div>
				<div class='top-comment-right'>
					<ul>
						<li><span class='left-at'><a href='#'>".$i['author']."</a></span></li>
						<li><span class='right-at'>".$i['ctime']."</span></li>
						<li></li>
					</ul>
				<p>".$i['content']."</p>
				</div>
				<div class='clearfix'> </div>
			</div>";}?>       
        <a href="single.php?<?php echo "p=1&id={$id}"; ?>">首页</a>
        <a href="single.php?<?php echo "p={$prev}&id={$id}";?>">上一页</a>
        <a href="single.php?<?php echo "p={$next}&id={$id}";?>">下一页</a>
        <a href="single.php?<?php echo "p={$allpage}&id={$id}"; ?>">尾页</a>
        <?php echo "总共{$allpage}页，当前{$p}/{$allpage}"; ?>
			<!--<div class="comments-top-top top-grid-comment">
				<div class="top-comment-left">
					<a href="#"><img class="img-responsive" src="images/co.png" alt=""></a>
				</div>
				<div class="top-comment-right">
					<ul>
						<li><span class="left-at"><a href="#">Admin</a></li>
						<li><span class="right-at">June 30, 2015 at 10.30am</span></li>
						<li><a class="reply" href="#">REPLY</a></li>
					</ul>
				<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum is that it has a more-or-less </p>
				</div>
				<div class="clearfix"> </div>
			</div>-->
            </div>
		<div class='artical-commentbox'>
			<h3>leave a comment</h3>
			<div class="table-form">
				<form action='pinglun.php' method='GET'>
				<input type="hidden" name="id" value="<?php echo $id; ?>" placeholder="">
					<!--<input name='username' type="text" class="textbox" value="Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name';}">
					<input type="text" class="textbox" value="Email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}">
					<input type="text" class="textbox" value="Phone number" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Phone number';}">-->
					<textarea name='gg' placeholder="Message" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}" required=required></textarea>	
					<input type="submit" value="Send">
				</form>
			</div>
		</div>	
	</div>
<!-- single -->
		</div>
	</div>
<!-- footer -->
	<div class="footer">
		<div class="container">
			<div class="footer-grids">
				<div class="col-md-3 footer-grid">
					<h3>cumque nihil impedit</h3>
					<div class="footer-grd-left">
						<img src="images/11.jpg" class="img-responsive" alt=" " />
					</div>
					<div class="footer-grd-left">
						<p>Nam libero tempore, cum 
							soluta nobis est eligendi optio cumque nihil impedit quo minus 
							id quod maxime placeat facere possimus, omnis voluptas assumenda 
							est, omnis dolor repellendus</p>
					</div>
					<div class="clearfix"> </div>
				</div>
				<div class="col-md-3 footer-grid">
					<h3>voluptas assumenda</h3>
					<ul>
						<li><a href="#">doloribus asperiores</a></li>
						<li><a href="#">Itaque earum rerum</a></li>
						<li><a href="#">deserunt mollitia</a></li>
						<li><a href="#">facilis est et expedita</a></li>
						<li><a href="#">occaecati cupiditate</a></li>
						<li><a href="#">deserunt mollitia laborum</a></li>
					</ul>
				</div>
				<div class="col-md-3 footer-grid">
					<h3>deserunt mollitia</h3>
					<ul>
						<li><a href="#">doloribus asperiores</a></li>
						<li><a href="#">Itaque earum rerum</a></li>
						<li><a href="#">deserunt mollitia</a></li>
						<li><a href="#">facilis est et expedita</a></li>
						<li><a href="#">occaecati cupiditate</a></li>
						<li><a href="#">deserunt mollitia laborum</a></li>
					</ul>
				</div>
				<div class="col-md-3 footer-grid">
					<h3>Flckr Posts</h3>
					<div class="footer-grd">
						<img src="images/7.jpg" class="img-responsive" alt=" " />
					</div>
					<div class="footer-grd">
						<img src="images/8.jpg" class="img-responsive" alt=" " />
					</div>
					<div class="footer-grd">
						<img src="images/9.jpg" class="img-responsive" alt=" " />
					</div>
					<div class="clearfix"> </div>
					<div class="footer-grd">
						<img src="images/10.jpg" class="img-responsive" alt=" " />
					</div>
					<div class="footer-grd">
						<img src="images/7.jpg" class="img-responsive" alt=" " />
					</div>
					<div class="footer-grd">
						<img src="images/8.jpg" class="img-responsive" alt=" " />
					</div>
					<div class="clearfix"> </div>
				</div>
				<div class="clearfix"> </div>
			</div>
		</div>
	</div>
	<div class="footer-bottom">
		<div class="container">
			<p>© 2015 Quickly. All rights reserved | Design by <a href="http://w3layouts.com/"> W3layouts</a></p>
		</div>
	</div>
<!-- //footer -->
<!-- for bootstrap working -->
		<script src="js/bootstrap.js"> </script>
<!-- //for bootstrap working -->
</body>
</html>